//
// Created by 11510 on 2024/6/11.
//

#include <iostream>
#include <math.h>
using namespace std;

//前向声明
class Point;

class Line{
public:
//    友元的成员函数形式
    float distance(const Point & lhs, const Point & rhs);

    void setX(Point &lhs, int x);
};



class Point{
private:
    int _ix;
    int _iy;

public:
    Point(int x = 0, int y = 0): _ix(x), _iy(y){}
//    友元声明
    friend float Line::distance(const Point & lhs, const Point & rhs);
    friend void Line::setX(Point &lhs, int x);
};


float Line::distance(const Point& lhs, const Point& rhs){
    return sqrt(pow(lhs._iy - rhs._iy, 2) + pow(lhs._ix - rhs._ix, 2));
}


void Line::setX(Point &lhs, int x) {
    lhs._ix = x;
}






void test0(){
    Point pt1(0, 0);
    Point pt2(1, 4);
    Line line;
    line.setX(pt2, 3);
    cout << line.distance(pt1, pt2);
}



int main() {
    test0();
    return 0;
}